package com.zjw.socket.demo.starter.messageService.service.impl;

import com.zjw.socket.demo.starter.messageService.Message;
import com.zjw.socket.demo.starter.messageService.MessageParser;
import com.zjw.socket.demo.starter.messageService.service.IConnectSession;
import com.zjw.socket.demo.starter.messageService.im.ImService;

public class IMServiceConnect implements IConnectSession {

  private final ImService service;

  private final long uid;
  public IMServiceConnect(ImService service, long uid) {
    this.service = service;
    this.uid = uid;
  }


  @Override
  public void writeMessage(Message message) {
    service.sendMessageToDestination(message);
  }

  @Override
  public void writeBytes(byte[] bytes) {
    service.sendMessageToDestination(MessageParser.fromByte(bytes));
  }

  @Override
  public void disconnect() {
    service.disConnect(uid);
  }

  @Override
  public void reconnect() {

  }
}
